package validator;

import exception.ParamCheckFailureException;

/**
 * 数值型参数校验接口方法定义
 *
 * @Author 小白龙
 * @Date 2021-01-05
 * @Version 1.0
 */
public interface INumberValidate extends IValidate<INumberValidate> {

    //-----------------------------------------------------------------------最大最小校验 start

    /**
     * 校验最大值
     *
     * @param max
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate max(Long max, String errorMessage) throws ParamCheckFailureException;

    /**
     * 校验最大值
     *
     * @param max
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate max(Long max) throws ParamCheckFailureException;


    /**
     * 校验最小值
     *
     * @param min
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate min(Long min) throws ParamCheckFailureException;

    /**
     * 校验最小值
     *
     * @param min
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate min(Long min, String errorMessage) throws ParamCheckFailureException;

    //-----------------------------------------------------------------------最大最小校验 end

    //---------------------------------------------------------------------- 范围校验 start

    /**
     * 校验数值范围 不包含最小最大值
     *
     * @param min
     * @param max
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate range(int min, int max, String errorMessage) throws ParamCheckFailureException;

    /**
     * 校验数值范围 不包含最小最大值
     *
     * @param min
     * @param max
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate range(int min, int max) throws ParamCheckFailureException;

    //---------------------------------------------------------------------- 范围校验 end

    //---------------------------------------------------------------------- 正负数校验 start
    /*
     * 需要实现的有： 大于0，大于等于0， 小于0， 小于等于0
     */
    int ZERO = 0;

    /**
     * 大于0
     *
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    default INumberValidate gtZero(String errorMessage) throws ParamCheckFailureException {
        return min(ZERO, errorMessage);
    }

    /**
     * 大于0
     *
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate gtZero() throws ParamCheckFailureException;

    /**
     * 大于等于0
     *
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    default INumberValidate gtOrEqZero(String errorMessage) throws ParamCheckFailureException {
        return min(ZERO, errorMessage);
    }

    /**
     * 大于等于0
     *
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate gtOrEqZero() throws ParamCheckFailureException;

    /**
     * 小于0
     *
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    default INumberValidate ltZero(String errorMessage) throws ParamCheckFailureException {
        return max(ZERO, errorMessage);
    }

    /**
     * 小于0
     *
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate ltZero() throws ParamCheckFailureException;

    /**
     * 小于等于0
     *
     * @param errorMessage
     * @return
     * @throws ParamCheckFailureException
     */
    default INumberValidate ltOrEqZero(String errorMessage) throws ParamCheckFailureException {
        return max(ZERO, errorMessage);
    }

    /**
     * 小于等于0
     *
     * @return
     * @throws ParamCheckFailureException
     */
    INumberValidate ltOrEqZero() throws ParamCheckFailureException;

    //---------------------------------------------------------------------- 正负数校验 end
}
